package com.shaoshaohuo.app.utils;

/**
 * 关于Area的工具类
 * Created by YinSF on 16/1/18.
 */
public class AreaUtil {

    public static boolean isZhiXiaShi(String areaName) {
        if ("北京".equals(areaName) || "天津".equals(areaName) || "上海".equals(areaName) || "重庆".equals(areaName) ||
                "北京市".equals(areaName) || "天津市".equals(areaName) || "上海市".equals(areaName) || "重庆市".equals(areaName)) {
            return true;
        }
        return false;
    }

    public static String getZhiXiaShiName(String areaName) {
        if ("北京".equals(areaName) || "北京市".equals(areaName)) {
            return "北京市";
        } else if ("天津".equals(areaName) || "天津市".equals(areaName)) {
            return "天津市";
        } else if ("上海".equals(areaName) || "上海市".equals(areaName)) {
            return "上海市";
        } else if ("重庆".equals(areaName) || "重庆市".equals(areaName)) {
            return "重庆市";
        }
        return areaName;
    }

    public static String getAreaName(String areaName) {
        if (isZhiXiaShi(areaName)) {
            return getZhiXiaShiName(areaName);
        } else {
            return areaName;
        }
    }

    public static String getAreaFullname(String areaId) {
//        if (areaId == null) {
//            return "全国";
//        }
//        Area currentArea = DaoUtils.findArea(areaId);
//        if (currentArea == null) {
            return "";
//        }
//        String currentLevelType = currentArea.getLevelType();
//        String currentAreaName = currentArea.getName();
//        if ("1".equals(currentLevelType)) {
//            return getAreaName(currentAreaName);
//        } else if ("2".equals(currentLevelType)) {
//            if (isZhiXiaShi(currentAreaName)) {
//                return getZhiXiaShiName(currentAreaName);
//            } else {
//                Area parentArea = DaoUtils.findArea(currentArea.getParentAreaId());
//                return getAreaFullname(parentArea.getAreaId()) + currentAreaName;
//            }
//        } else if ("3".equals(currentLevelType)) {
//            Area parentArea = DaoUtils.findArea(currentArea.getParentAreaId());
//            return getAreaFullname(parentArea.getAreaId()) + currentAreaName;
//        }
//        return "";
    }
}
